<?php
$http = new swoole_http_server("0.0.0.0", 9503);
$http->set([
    'worker_num'=>5
]);
$http->on("WorkerStart", function ($server) {
    header("Content-Type: text/html; charset=UTF-8");
    require_once 'autoLoad.php';
});

$http->on("request", function ($request, $response) {

    $_SERVER =[];
    $_GET =[];
    $_POST =[];
    if(isset($request->server)){
        foreach ($request->server as $k=>$v){
            $_SERVER[strtoupper($k)] = $v;
        }
    }
    if(isset($request->get)){
        foreach ($request->get as $k=>$v){
            $_GET[strtoupper($k)] = $v;
        }
    }
    if(isset($request->post)){
        foreach ($request->post as $k=>$v){
            $_POST[strtoupper($k)] = $v;
        }
    }
    if(isset($request->header)){
        foreach ($request->header as $k=>$v){
            $_SERVER[strtoupper($k)] = $v;
        }
    }
    $response->header("Content-Type", "text/plain");
    ob_start();
    core\Thinksp::run();
    $res =ob_get_contents();
    ob_clean();
    $response->end($res);
});

$http->start();
